package com.linxi.rpccompensation.config;

import cn.hutool.core.lang.UUID;
import com.linxi.rpccompensation.annotation.Compensation;
import com.linxi.rpccompensation.constant.Constant;
import com.linxi.rpccompensation.entity.SysPushLog;
import com.linxi.rpccompensation.service.PushLogService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * springboot运行完成后执行
 *
 * @author lx
 * createTime 2018-11-07 22:37
 **/
@Component
public class AfterRunner implements ApplicationRunner {

	@Resource
	private PushLogService pushLogService;

	@Override
	public void run(ApplicationArguments args) {
//		this.saveLog();
//		hardwareService.pushAll();
	}

	@Compensation(api = Constant.PUSH_USERINFO)
	public SysPushLog saveLog() {
		SysPushLog pushLog = new SysPushLog();
		pushLog.setId(UUID.fastUUID().toString());
		pushLog.setData("{'pwd':'hello'}");
		pushLog.setTime(new Date());
		pushLog.setStatus(1);
		pushLogService.save(pushLog);
		return pushLog;
	}
}
